
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>引用 · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="generic.html" />
    
    
    <link rel="prev" href="combining.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    OpenAPI 文档结构
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.1.1" data-path="../openapi/openapi.html">
            
                <a href="../openapi/openapi.html">
            
                    
                    openapi
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.1.2" data-path="../openapi/info.html">
            
                <a href="../openapi/info.html">
            
                    
                    info
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.1.3" data-path="../openapi/paths.html">
            
                <a href="../openapi/paths.html">
            
                    
                    paths
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.1.3.1" data-path="../openapi/url.html">
            
                <a href="../openapi/url.html">
            
                    
                    /add, /del, ...
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.1.3.1.1" data-path="../openapi/method.html">
            
                <a href="../openapi/method.html">
            
                    
                    get, post, ...
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.1.3.1.1.1" data-path="../openapi/parameters.html">
            
                <a href="../openapi/parameters.html">
            
                    
                    parameters
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.1.3.1.1.2" data-path="../openapi/requestBody.html">
            
                <a href="../openapi/requestBody.html">
            
                    
                    requestBody
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.1.3.1.1.3" data-path="../openapi/responses.html">
            
                <a href="../openapi/responses.html">
            
                    
                    responses
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.1.3.1.1.3.1" data-path="../openapi/response_code.html">
            
                <a href="../openapi/response_code.html">
            
                    
                    200, 400, ...
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.1.3.1.1.3.1.1" data-path="../openapi/content.html">
            
                <a href="../openapi/content.html">
            
                    
                    content
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.1.3.1.1.3.1.1.1" data-path="../openapi/media.html">
            
                <a href="../openapi/media.html">
            
                    
                    text/plain
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.1.3.1.1.3.1.1.1.1" data-path="../openapi/schema.html">
            
                <a href="../openapi/schema.html">
            
                    
                    schema
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

            </ul>
            
        </li>
    

            </ul>
            
        </li>
    

            </ul>
            
        </li>
    

            </ul>
            
        </li>
    

            </ul>
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.1.4" data-path="../openapi/components.html">
            
                <a href="../openapi/components.html">
            
                    
                    components
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="./">
            
                <a href="./">
            
                    
                    常见的 schema 规则
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="string.html">
            
                <a href="string.html">
            
                    
                    字符串
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="number.html">
            
                <a href="number.html">
            
                    
                    数字
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.3" data-path="json.html">
            
                <a href="json.html">
            
                    
                    json object
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.4" data-path="array.html">
            
                <a href="array.html">
            
                    
                    数组
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.5" data-path="boolean.html">
            
                <a href="boolean.html">
            
                    
                    布尔值
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.6" data-path="combining.html">
            
                <a href="combining.html">
            
                    
                    组合
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.2.7" data-path="ref.html">
            
                <a href="ref.html">
            
                    
                    引用
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.8" data-path="generic.html">
            
                <a href="generic.html">
            
                    
                    通用
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >引用</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="&#x5F15;&#x7528;">&#x5F15;&#x7528;</h1>
<p>&#x5982;&#x679C;&#x4E00;&#x4E9B; schema &#x88AB;&#x591A;&#x4E2A;&#x5730;&#x65B9;&#x4F7F;&#x7528;&#xFF0C;&#x4E3A;&#x4E86;&#x907F;&#x514D;&#x6587;&#x6863;&#x4E0A;&#x7684;&#x91CD;&#x590D;&#xFF0C;&#x66F4;&#x5E38;&#x89C1;&#x7684;&#x505A;&#x6CD5;&#x662F;&#x5C06;&#x8FD9;&#x4E00;&#x90E8;&#x5206; schema &#x58F0;&#x660E;&#x4E3A;&#x4E00;&#x4E2A;&#x7247;&#x6BB5;&#xFF0C;&#x5176;&#x4ED6;&#x6587;&#x6863;&#x901A;&#x7528;&#x5F15;&#x7528;&#x7684;&#x65B9;&#x5F0F; &#x6765;&#x5F15;&#x5165;&#x8BE5;&#x7247;&#x6BB5;&#x3002;</p>
<h2 id="ref">$ref</h2>
<p>&#x5F15;&#x7528;&#x53EF;&#x4EE5;&#x662F;&#x672C;&#x5730;&#x5F15;&#x7528;&#xFF0C;&#x4E5F;&#x53EF;&#x4EE5;&#x662F;&#x7F51;&#x7EDC;&#x5F15;&#x7528;&#x3002; &#x53EF;&#x4EE5;&#x662F;&#x6574;&#x4E2A;&#x6587;&#x6863;&#x5F15;&#x7528;&#xFF0C;&#x4E5F;&#x53EF;&#x4EE5;&#x662F;&#x6587;&#x6863;&#x5185;&#x7684;&#x7247;&#x6BB5;&#x5F15;&#x7528;</p>
<ol>
<li><p>&#x6587;&#x6863;&#x5185;&#x7684;&#x672C;&#x5730;&#x5F15;&#x7528;</p>
<pre><code class="lang-yaml">$ref: <span class="hljs-string">&apos;#/components/schema/myElement&apos;</span>
</code></pre>
</li>
<li><p>&#x540C;&#x4E00;&#x4E2A;&#x670D;&#x52A1;&#x5668;&#x7684;&#x7247;&#x6BB5;&#x5F15;&#x7528;</p>
<pre><code class="lang-yaml">$ref: <span class="hljs-string">&apos;document.yaml#/components/schema/myElement&apos;</span>
$ref: <span class="hljs-string">&apos;../document.yaml#/components/schema/myElement&apos;</span>
$ref: <span class="hljs-string">&apos;../another-folder/document.yaml#/components/schema/myElement&apos;</span>
</code></pre>
</li>
<li><p>URL&#x7247;&#x6BB5;&#x5F15;&#x7528;</p>
<pre><code class="lang-yaml">$ref: <span class="hljs-string">&apos;http://my.site.com/document.yaml#/components/schema/myElement&apos;</span>
$ref: <span class="hljs-string">&apos;//my.site.com/document.yaml#/components/schema/myElement&apos;</span>
</code></pre>
</li>
</ol>
<p><code>$ref</code> &#x548C; allOf&#xFF0C;oneOf&#xFF0C;anyOf &#x7B49;&#x5173;&#x952E;&#x5B57;&#x4E00;&#x8D77;&#x4F7F;&#x7528;&#x3002;&#x4ECE;&#x4E00;&#x4E9B;&#x57FA;&#x672C;&#x7684;&#x7247;&#x6BB5;&#xFF0C;&#x65E0;&#x9700;&#x5927;&#x91CF;&#x91CD;&#x590D;&#x5C31;&#x53EF;&#x4EE5;&#x6784;&#x5EFA;&#x51FA;&#x4E00;&#x4E2A;&#x975E;&#x5E38;&#x5F3A;&#x5927;&#x7684;&#x7ED3;&#x6784;</p>
<h2 id="&#x6CE8;&#x610F;&#x4E8B;&#x9879;">&#x6CE8;&#x610F;&#x4E8B;&#x9879;</h2>
<ol>
<li><p>&#x89E3;&#x6790;&#x7684;&#x65F6;&#x5019; <code>$ref</code> &#x5144;&#x5F1F;&#x8282;&#x70B9;&#x90FD;&#x4F1A;&#x88AB;&#x5FFD;&#x7565;&#xFF0C; &#x6BD4;&#x5982;&#x4E0B;&#x9762;&#x7684; <code>description</code> &#x548C; <code>default</code> &#x5B57;&#x6BB5;</p>
<pre><code class="lang-yaml"><span class="hljs-attr">components:</span>
<span class="hljs-attr">  schemas:</span>
<span class="hljs-attr">    Date:</span>
<span class="hljs-attr">      type:</span> string
<span class="hljs-attr">      format:</span> date
<span class="hljs-attr">    DateWithExample:</span>
      $ref: <span class="hljs-string">&apos;#/components/schemas/Date&apos;</span>
<span class="hljs-attr">      description:</span> Date schema extended with a `default` value... Or not?
<span class="hljs-attr">      default:</span> <span class="hljs-number">2000</span><span class="hljs-bullet">-01</span><span class="hljs-bullet">-01</span>
</code></pre>
</li>
<li><p><code>/</code>&#x548C;<code>~</code>&#x662F;JSON&#x6307;&#x9488;&#x4E2D;&#x7684;&#x7279;&#x6B8A;&#x5B57;&#x7B26;&#x3002;&#x53EF;&#x80FD;&#x4F1A;&#x88AB;&#x8F6C;&#x4E49;</p>
<ul>
<li><code>~</code> -&gt; <code>~0</code></li>
<li><code>/</code> -&gt; <code>~1</code></li>
</ul>
<pre><code class="lang-yaml"><span class="hljs-comment"># &#x4E0B;&#x9762;&#x4E24;&#x4E2A;&#x90FD;&#x662F;&#x5408;&#x6CD5;&#x7684;</span>
$ref: <span class="hljs-string">&apos;#/paths/blogs{blog_id}/new~posts&apos;</span>
$ref: <span class="hljs-string">&apos;#/paths/~1blogs~1{blog_id}~1new~0posts&apos;</span>
</code></pre>
</li>
</ol>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="combining.html" class="navigation navigation-prev " aria-label="Previous page: 组合">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="generic.html" class="navigation navigation-next " aria-label="Next page: 通用">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"引用","level":"1.2.7","depth":2,"next":{"title":"通用","level":"1.2.8","depth":2,"path":"schema/generic.md","ref":"schema/generic.md","articles":[]},"previous":{"title":"组合","level":"1.2.6","depth":2,"path":"schema/combining.md","ref":"schema/combining.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":["livereload"],"pluginsConfig":{"livereload":{},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"schema/ref.md","mtime":"2020-08-17T07:14:59.617Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2020-08-17T10:32:10.207Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-livereload/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

